package club.easin.enums;

import java.util.Arrays;
import java.util.Optional;

public class  DbEmHelper {
    public enum DbTypeEm {
        db0(0, "db0(默认master)", -1);

        public static Optional<DbTypeEm> getDbTypeBySlaveNum(int slaveNum) {
              return  Arrays.stream(DbTypeEm.values()).filter(b -> b.getSlaveNum() == slaveNum).findFirst();
        }

        DbTypeEm(int code, String des, int slaveNum) {

            this.code = code;
            this.des = des;
            this.slaveNum = slaveNum;

        }

        private int code;
        private String des;
        private int slaveNum;

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public String getDes() {
            return des;
        }

        public void setDes(String des) {
            this.des = des;
        }

        public int getSlaveNum() {
            return slaveNum;
        }

        public void setSlaveNum(int slaveNum) {
            this.slaveNum = slaveNum;
        }
    }

}

